//
//  SNewsMyTwoTableViewCell.m
//  News
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SNewsMyTwoTableViewCell.h"

@implementation SNewsMyTwoTableViewCell


-(void)dealloc
{
    [_TwocellImageViewOne release];
    [_TWocellImageViewTwo release];
    [_TwocellImageViewThree release];
    [_TwocellLabelOne release];
    [_TwocellLabelTwo release];
    [_model release];
    [super dealloc];
    
}

- (void)awakeFromNib {
    // Initialization code
}
/**
 *初始化
 *
 */
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.TwocellImageViewOne = [[UIImageView alloc] init];
        
//        _TwocellImageViewOne.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_TwocellImageViewOne];
        [_TwocellImageViewOne release];
        
        self.TWocellImageViewTwo = [[UIImageView alloc] init];
//        _TWocellImageViewTwo.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_TWocellImageViewTwo];
        [_TWocellImageViewTwo release];
        
        
        self.TwocellImageViewThree = [[UIImageView alloc] init];
//        _TwocellImageViewThree.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_TwocellImageViewThree];
        [_TwocellImageViewThree release];
        
        self.TwocellLabelOne = [[UILabel alloc] init];
//        _TwocellLabelOne.backgroundColor = [UIColor grayColor];
        
        [self.contentView addSubview: _TwocellLabelOne];
        [_TwocellLabelOne release];
        
        self.TwocellLabelTwo = [[UILabel alloc] init];
//        _TwocellLabelTwo.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:_TwocellLabelTwo];
        [_TwocellLabelTwo release];
        
        
        
    }
    
    return self;
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];


    
    _TwocellImageViewOne.frame = CGRectMake(0, self.contentView.frame.size.height / 3, self.contentView.frame.size.width / 3 ,self.contentView.frame.size.height - self.contentView.frame.size.height / 3 );
    
    _TWocellImageViewTwo.frame = CGRectMake(_TwocellImageViewOne.frame.size.width , self.contentView.frame.size.height / 3, self.contentView.frame.size.width / 3 , self.contentView.frame.size.height - self.contentView.frame.size.height / 3 );
    
    _TwocellImageViewThree.frame = CGRectMake(_TWocellImageViewTwo.frame.size.width *2   , self.contentView.frame.size.height / 3, self.contentView.frame.size.width / 3 , self.contentView.frame.size.height - self.contentView.frame.size.height / 3 );
    
    _TwocellLabelOne.frame = CGRectMake(0, 10, self.contentView.frame.size.width / 3 * 2, 22);
    _TwocellLabelTwo.frame = CGRectMake(self.contentView.frame.size.width / 3 * 2 + 20, 10, self.contentView.frame.size.width / 3, 22);
    
    
    
}



-(void)setModel:(SNews *)model
{
    if (model != _model) {
        [_model release];
        _model = [model retain];
    }
    NSURL * url = [NSURL URLWithString:model.imgsrc];
    
    [_TwocellImageViewOne sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    
 NSURL *url1 =  [[model.imgextra  objectAtIndex:0] objectForKey:@"imgsrc"];
    
    [_TWocellImageViewTwo sd_setImageWithURL:url1 placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    
    NSURL *url2 =  [[model.imgextra  objectAtIndex:1] objectForKey:@"imgsrc"];
    
    [_TwocellImageViewThree sd_setImageWithURL:url2 placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    
    _TwocellLabelOne.text = model.title;
    NSString * str = [NSString stringWithFormat:@"%ld跟帖", (long)model.replyCount];
    _TwocellLabelTwo.text = str;
    

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
